package cn.wusifx.zabbix.request.builder.event;

import cn.wusifx.zabbix.request.BaseRequest;
import cn.wusifx.zabbix.request.builder.RequestBuilder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * https://www.zabbix.com/documentation/4.0/manual/api/reference/event/acknowledge
 */
public class EventAcknowledgeRequestBuilder  extends RequestBuilder<Map<String,Object>> {
    private List<String> eventIds =new ArrayList<>();
    private Integer action;
    public EventAcknowledgeRequestBuilder(String auth) {
        super("event.acknowledge", auth);
        baseRequest.setParams(new HashMap<>());
    }

    public EventAcknowledgeRequestBuilder(Long id, String auth) {
        super("event.acknowledge", id, auth);
        baseRequest.setParams(new HashMap<>());
    }

    public EventAcknowledgeRequestBuilder setParam(String key, Object value){
        baseRequest.getParams().put(key,value);
        return this;
    }

    public EventAcknowledgeRequestBuilder setParams(Map<String,Object> params){
        baseRequest.getParams().putAll(params);
        return this;
    }

    public List<String> getEventIds() {
        return eventIds;
    }

    public EventAcknowledgeRequestBuilder setEventIds(List<String> eventIds) {
        this.eventIds = eventIds;
        return this;
    }

    public EventAcknowledgeRequestBuilder addEventId(String eventId) {
        this.eventIds.add(eventId);
        return this;
    }

    public Integer getAction() {
        return action;
    }

    public EventAcknowledgeRequestBuilder setAction(Integer action) {
        this.action = action;
        return this;
    }

    @Override
    public BaseRequest<Map<String, Object>> builder() {
        baseRequest.getParams().put("eventids",eventIds);
        baseRequest.getParams().put("action",action);
        return baseRequest;
    }
}
